package com.ljx.thread.pollThread07;

import java.util.ArrayList;
import java.util.concurrent.*;

/**
 * @author LJX
 * @Description: TODO
 * @Date: 2022/11/2 20:07
 * @Version 1.0
 */
public class ConnectionThread02 {
	public static void main(String[] args) {
		// 非线程安全的集合
		//		ArrayList<Object> arrayList = new ArrayList<>();
		// 集合中安全的集合
		CopyOnWriteArraySet<Object> objects1 = new CopyOnWriteArraySet<>();
		ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<>();
		CopyOnWriteArrayList<Object> objects = new CopyOnWriteArrayList<>();
		for (int i = 0; i < 10; i++) {
			final int a=i;
			new Thread(new Runnable() {
				@Override
				public void run() {
					objects.add(a);
					System.out.println(objects);
				}
			}).start();
		}

	}
}
